package com.itbaizhan.zookeeper.rmi.service;

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

public class RMIServer {
    public static void main(String [] args) throws Exception {
        System.out.println("rmi server runing........");
        //定义发布RMI服务时使用的端口
        int port = 1099;
        //定义url
        String url = "rmi://localhost:1099/com.itbaizhan.zookeeper.rmi.service.HelloSreviceImpl";
        //注册服务：在JNDI中创建一个注册表
        LocateRegistry.createRegistry(port);
        //绑定服务：将RMI服务的实现类对象与url绑定
        Naming.rebind(url,new HelloSreviceimpl());
    }
}
